package cn.ustb.dao;

import cn.ustb.entity.StudentOptCourse;
import org.apache.ibatis.annotations.*;

import java.util.List;

public interface StudentOptCourseDao {
    @Select({"<script>",
            "SELECT * FROM StudentOptCourse",
            "<if test = \"studentId!=null\">"+
                    " where studentId =#{studentId}"+
                    " </if>",
            "</script>"
    })
    List<StudentOptCourse> getAll(@Param("studentId") String studentId);

    @Select("select * from StudentOptCourse where studentId = #{studentId}")
    StudentOptCourse getByStudentId(String studentId);

    @Select("select * from StudentOptCourse where studentId = #{studentId} and courseId =#{courseId}")
    StudentOptCourse getByStudentIdandCourseId(StudentOptCourse studentOptCourse);

    @Insert("insert into StudentOptCourse values(#{studentId},#{courseId})")
    void insert(StudentOptCourse studentOptCourse);

    @Update("update StudentOptCourse set CourseId = #{courseId} where studentId =#{studentId}")
    void update(StudentOptCourse studentOptCourse);

    @Delete("delete from StudentOptCourse where studentId = #{studentId}")
    void delete(String studentId);
}
